QuickOPC User's Guide and Reference
Variant Type (VarType) in OPC Classic
Fundamentals > Components and Objects > Helper Types > Data Objects > Variant Type (VarType) in OPC Classic

In some places in OPC, your code needs to indicate which type of data you expect to receive back, or (in the opposite direction), you receive indication about which type of data certain piece of information is. OPC uses Windows VARTYPE for this (describes a data contained in Windows VARIANT).

QuickOPC.NET gives you a .NET encapsulation for indicating variant data types, so that you do not have to look up and code in the numeric values of Windows VARTYPE. Instead, wherever you see that a method argument, a property, or other element is of VarType type, you can supply one of the constants defined in the VarTypes enumeration. For example, VarTypes.I2 denotes a 16-bit signed integer, VarTypes.R4 denotes a 32-bit float, and VarTypes.BStr denotes a string. For arrays of values, use constants named VarTypes.ArrayOfXXXX (e.g. VarTypes.ArrayOfI4), or (if the element type is determined in the run time) the VarType.MakeArrayType method.

Note: Microsoft.NET framework contains a similar type, System.Runtime.InteropServices.VarEnum. The types have some similarities, but should not be confused.

QuickOPC-COM gives you an enumeration for indicating variant data types, so that you do not have to look up and code in the numeric values of Windows VARTYPE. Instead, wherever you see that a method argument, a property, or other element accepts a data type, you can supply one of the constants defined in the VarTypes enumeration. For example, I2 denotes a 16-bit signed integer, R4 denotes a 32-bit float, and BStr denotes a string. For arrays of values, use logical ‘or’ to combine the element type with the Array constant. Note, however, that the enumeration symbols are only accessible if you reference or import the EasyOPC Type Library, and not all languages and tools are capable of doing it.

See Also